using NL.Combat;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace NL.RPG
{
    public class EDGE : _ChildOf<ICombatObj>, IEdge<ATT>
    {
      
        public ICombatObj CombatOwner => _Parent;
        public ATT More;
        public virtual ATT Attacky
        {
            get
            {
                ParentProperty= ParentProperty ?? GetComponentInParent<PROPERTY>();
                var att = ParentProperty != null ? ParentProperty.GenrateAttacky() : new ATT();
                att.Add(More);
                return att;


            }
        }

        protected PROPERTY ParentProperty;
        protected override void Awake()
        {
            base.Awake();

            ParentProperty = GetComponentInParent<PROPERTY>();
        }




        public virtual bool CanHitOn => true;


        public virtual void Hit(BODY who, IHurt hurt)
        {
            OnHitOne(who, hurt);

            if (_ONHIT != null) _ONHIT.Invoke(this, who, hurt);

        }

        protected virtual void OnHitOne(BODY who, IHurt hurt)
        {

        }

        UnityAction<EDGE, BODY, IHurt> _ONHIT;
        public EDGE WaitHit(UnityAction<EDGE, BODY, IHurt> _on)
        {
            _ONHIT = _on;
            return this;
        }
    }
}

